#普通装饰器
# def outer(func):
#     def inner():
#         print('chanyeol Rapper')
#         func()
#         print('chanbaek is real')
#     return inner
#
# @outer
# def love():
#     print('baekhyun Singer')
# love()

#装饰器嵌套
# def wanna(a):
#     def one():
#         print('kuanlin Rapper')
#         a()
#         print('jihoon Dancer')
#     return one
#
# def outer(func):
#     def inner():
#         print('chanyeol Rapper')
#         func()
#         print('chanbaek is real')
#     return inner
# @wanna
# @outer
# def love():
#     print('baekhyun Singer')
# love()

#对带参数装饰器进行装饰
'''
def outer(func):
    def inner(var):
        print('chanyeol Rapper')
        func(var)
        print('chanbaek is real!')
    return inner

@outer
def love(name):
    print(f'{name} Singer')
love('baekhyun')
'''

#带多参数的装饰器装饰
# def outer(func):
#     def inner(name,name1,*args,**kwargs):
#         print('chanyeol Rapper')
#         func(name,name1,*args,**kwargs)
#         print('chanbaek is real!')
#     return inner
#
# @outer
# def love(name,name1,*args,**kwargs):
#     print(f'{name}和{name1} Singer')
#     print('茶蛋成员还有',args)
#     print(kwargs)
# love('baekhyun','chen','kai','D.O.','suho','sehun','xiumin',kuanlin='WANNAONE',茶蛋='EXO')

#带参数装饰器修饰无参数函数
# def kuozhan(n):
#     def outer(func):
#         print(n)
#         def inner1():
#             print('chanyeol Rapper')
#             func()
#             print('baekhyun Singer')
#         def inner2():
#             print('largeteam forever')
#         if n=='EXO':
#             return inner1
#         else:
#             return inner2
#     return outer
# @kuozhan('EXO')
# def love():
#     print('chanbaek is real')
# love()

#用类内部的方法进行修饰
# def outer(func):
#     def inner(var):
#         print('kuanlin Rapper')
#         func(var)
#         print('jihoon Dancer')
#     return inner
# class Demo():
#     @outer
#     def love(self):
#         print('largeteam WANNAONE')
# # Demo.love()
# a=Demo()
# a.love()

#用类装饰器修饰原函数
'''
class Outer():
    def __call__(self,func):
        self.func=func
        return self.newinner
    def newinner(self,s):
        print('chanyeol Rapper')
        self.func(s)
        print('chanbaek is real')

@Outer()
def love(who):
    print(f'baekhyun和{who} Singer')
love('chen')
'''

#用类方法装饰函数
# class Outer():
#     def newinner(func):
#         Outer.func=func
#         return Outer.inner
#     def inner():
#         print('chanyeol Rapper')
#         Outer.func()
#         print('chanbaek is real')
#
# @Outer.newinner
# def love():
#     print('baekhyun Singer')
# love()